<script>
import {removeContainer} from "@/api/container";
import {isFirstLegRole} from "@/utils/common";

export default {
  name: "DelContainerBtn",
  props: {
    data: {
      type: Object,
      required: true,
    }
  },
  data(){
    return {
      loading: false,
    }
  },
  methods: {
    isFirstLegRole,
    remove() {
      let title = '确认撤销？'
      this.$confirm('', title)
        .then(res=>{
          this.loading = true;
          removeContainer(this.data.id)
            .then(res=>{
              this.loading = false;
              this.$emit('changeRow')
              this.$emit('delRow')
              this.$sMsg(res.message)
            })
        })
        .catch(res=>{

        })

    }
  }
}
</script>

<template>
  <el-button @click="remove" type="danger" :loading="loading" v-if="data.status === 'wait_make_cabinet' && isFirstLegRole()">撤销</el-button>
</template>

<style scoped lang="scss">

</style>
